package com.ruoyi.basebill.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basebill.domain.OmsStocktransferbill;
import com.ruoyi.basebill.service.IOmsStocktransferbillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存调拨单Controller
 * 
 * @author xiefeng
 * @date 2023-02-15
 */
@RestController
@RequestMapping("/settlementCenter/basebill/stocktransferbill")
public class OmsStocktransferbillController extends BaseController
{
    @Autowired
    private IOmsStocktransferbillService omsStocktransferbillService;

    /**
     * 查询库存调拨单列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:stocktransferbill:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmsStocktransferbill omsStocktransferbill)
    {
        startPage();
        List<OmsStocktransferbill> list = omsStocktransferbillService.selectOmsStocktransferbillList(omsStocktransferbill);
        return getDataTable(list);
    }

    /**
     * 导出库存调拨单列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:stocktransferbill:export')")
    @Log(title = "库存调拨单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OmsStocktransferbill omsStocktransferbill)
    {
        List<OmsStocktransferbill> list = omsStocktransferbillService.selectOmsStocktransferbillDetailList(omsStocktransferbill);
        ExcelUtil<OmsStocktransferbill> util = new ExcelUtil<OmsStocktransferbill>(OmsStocktransferbill.class);
        util.exportExcel(response, list, "库存调拨单数据");
    }

    /**
     * 获取库存调拨单详细信息
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:stocktransferbill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(omsStocktransferbillService.selectOmsStocktransferbillById(id));
    }

    /**
     * 新增库存调拨单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:stocktransferbill:add')")
    @Log(title = "库存调拨单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmsStocktransferbill omsStocktransferbill)
    {
        omsStocktransferbill.setCreatetime(new Date());
        return toAjax(omsStocktransferbillService.insertOmsStocktransferbill(omsStocktransferbill));
    }

    /**
     * 修改库存调拨单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:stocktransferbill:edit')")
    @Log(title = "库存调拨单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmsStocktransferbill omsStocktransferbill)
    {
        return toAjax(omsStocktransferbillService.updateOmsStocktransferbill(omsStocktransferbill));
    }

    /**
     * 删除库存调拨单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:stocktransferbill:remove')")
    @Log(title = "库存调拨单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(omsStocktransferbillService.deleteOmsStocktransferbillByIds(ids));
    }
}
